﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="到货数据校验.aspx.cs" Inherits="syc.Sale.到货数据校验" %>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">

<asp:Label ID="SqlText" runat="server" Text="" Visible="false"></asp:Label>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>">
</asp:SqlDataSource>

<div id="wintop" class="wintop">到货数据对比校检</div>

<asp:Panel ID="Panel1" runat="server" CssClass="panel">
<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
SelectCommand="select ID, 名称 FROM 原料供货单位"></asp:SqlDataSource>
供货单位：<asp:DropDownList 
    ID="GongHuo" runat="server" DataSourceID="SqlDataSource2"  Width="121px"
    DataTextField="名称" DataValueField="ID"></asp:DropDownList>
<span style="display:inline-block;width:50px;text-align:right;">原料类别：</span><asp:DropDownList ID="YuanLiao" runat="server" Width="125">
    <asp:ListItem Text="油管光管(J55)" Value="1"></asp:ListItem>
    <asp:ListItem Text="套管光管(J55)" Value="2"></asp:ListItem>
    <asp:ListItem Text="油管接箍光管(J55)" Value="3"></asp:ListItem>
    <asp:ListItem Text="套管接箍光管(J55)" Value="4"></asp:ListItem>
    <asp:ListItem Text="成品油管接箍(J55)" Value="5"></asp:ListItem>
    <asp:ListItem Text="成品套管接箍(J55)" Value="6"></asp:ListItem>
    
    <asp:ListItem Text="油管光管(N80)" Value="101"></asp:ListItem>
    <asp:ListItem Text="套管光管(N80)" Value="102"></asp:ListItem>
    <asp:ListItem Text="油管接箍光管(N80)" Value="103"></asp:ListItem>
    <asp:ListItem Text="套管接箍光管(N80)" Value="104"></asp:ListItem>
    <asp:ListItem Text="成品油管接箍(N80)" Value="105"></asp:ListItem>
    <asp:ListItem Text="成品套管接箍(N80)" Value="106"></asp:ListItem>
        </asp:DropDownList> 
<span style="display:inline-block;width:50px;text-align:right;">数据源：</span><asp:DropDownList 
        ID="LaiYuan" runat="server" Width="115" 
        onselectedindexchanged="LaiYuan_SelectedIndexChanged" AutoPostBack="true">
    <asp:ListItem Text="全部" Value="全部"></asp:ListItem>
    <asp:ListItem Text="供应处" Value="供应处"></asp:ListItem>
    <asp:ListItem Text="物流中心" Value="物流中心"></asp:ListItem>
    </asp:DropDownList>
<span style="display:inline-block;width:5px;text-align:right;">质保书重量：</span><asp:TextBox ID="weight" runat="server" CssClass="textbox" Width="70"></asp:TextBox>
<br />
    
到货日期：<asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="115"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" />
<span style="display:inline-block;width:50px;text-align:center;">至</span><asp:TextBox ID="Date2" runat="server" CssClass="textbox" Width="115"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" />

<span style="display:inline-block;width:30px;text-align:center;"></span>
<asp:Button ID="Button_Query" runat="server" Text="查 询" UseSubmitBehavior="false" 
        CssClass="button" onclick="Button_Query_Click" />

</asp:Panel>

<style>td.grid{cursor:default;}</style>

<div class="gridframe">
    <div class="gridview">
    
        <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
            <tr>
	            <td class="grid-title">数据对比</td>
	        </tr>
	        <tr>
	            <td class="grid-back">
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid" 
                        DataSourceID="SqlDataSource1"
                        PageSize="100"
                        GridLines="None" ondatabound="GridView1_DataBound"   DataKeyNames="到货日期"
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False" >
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <Columns>                      
                            <asp:TemplateField HeaderText="到货日期">
                                <ItemTemplate>
                                    <asp:Label ID="Label_ri" runat="server" Text='<%# Eval("到货日期","{0:yyyy年MM月dd日}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="80px" />
                            </asp:TemplateField>                       
                            <asp:TemplateField HeaderText="数据源" >
                                <ItemTemplate>
                                    <asp:Label ID="Label_sj" runat="server" Text='<%# Eval("数据") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="80px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="供货单位" >
                                <ItemTemplate>
                                    <asp:Label ID="Label_dw" runat="server" Text='<%# Eval("供货单位") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="80px" />
                            </asp:TemplateField>
                             <asp:TemplateField HeaderText="原料类别" >
                                <ItemTemplate>
                                    <asp:Label ID="Label_yl" runat="server" Text='<%# Eval("原料") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="80px" />
                            </asp:TemplateField>
                            
                             <asp:TemplateField HeaderText="质保书磅重(吨)">
                                <ItemTemplate>
                                    <asp:Label ID="Label_myzl" runat="server" Text='<%# Eval("总重量") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="100px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="实际磅重(吨)">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zl" runat="server" Text='<%# Eval("磅重") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="100px" />
                            </asp:TemplateField>
                            
                             <asp:TemplateField HeaderText="磅差(吨)">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bc" runat="server" Text='<%# Eval("磅差") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="100px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="支数(支)">
                                <ItemTemplate>
                                    <asp:Label ID="Label_zs" runat="server" Text='<%# Eval("总支数") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="center" Width="80px" />
                            </asp:TemplateField>
                           
                           
                            
                        </Columns>
                        <SelectedRowStyle CssClass="grid-row-selected" />
                      </asp:GridView>
	            </td>
            </tr>
            <tr>
	            <td>   
	                <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                    ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                
                                <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><asp:Label ID="Label9" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>

	            </td>
            </tr>
        </table>
        

    </div>
</div>

</form>
<script>

    var msg = '<%=this.msg %>';
    if (msg != '') setTimeout('alert(msg)', 100);

    var GridView1 = document.getElementById("GridView1");
    var Rows = GridView1.rows;
    var date = '';
    var data = '';
    var LaiYuan = document.getElementById("LaiYuan");
        for (var i = 1; i < Rows.length; i++) {
            if (date == Rows[i].cells[0].innerText.replace(' ', '')) {
                if (data != Rows[i].cells[4].innerText.replace(' ', '')
        + Rows[i].cells[5].innerText.replace(' ', '')
        + Rows[i].cells[6].innerText.replace(' ', '')
        + Rows[i].cells[7].innerText.replace(' ', '')) {
                    Rows[i].style.backgroundColor = 'red';
                }
            }
            else {                
                if (Rows.length == 2 && LaiYuan.selectedIndex == "0") {
                    Rows[i].style.backgroundColor = 'red';
                }
                date = Rows[i].cells[0].innerText.replace(' ', '');
                data = Rows[i].cells[4].innerText.replace(' ', '')
        + Rows[i].cells[5].innerText.replace(' ', '')
        + Rows[i].cells[6].innerText.replace(' ', '')
        + Rows[i].cells[7].innerText.replace(' ', '');
            }
        }
    

    var rows = document.getElementById("GridView1").rows;
    var sum1 = 0, sum2 = 0, sum3 = 0, sum4 = 0;
    var col = 3;
    if (rows[0].cells.length == 14) col = 4;
    for (i = 1; i < rows.length; i++) {
        sum1 += Number(rows[i].cells[col+1].innerText);
        sum2 += Number(rows[i].cells[col + 2].innerText);
        sum3 += Number(rows[i].cells[col + 3].innerText);
        sum4 += Number(rows[i].cells[col + 4].innerText);
    }
    var total = document.getElementById("Label_Total");
    total.innerHTML += " </br>质保书总磅量：" + fixFloatZ(sum1, 3) + "吨 实际总磅量：" + fixFloatZ(sum2, 3) + " 吨 磅差：" + fixFloatZ(sum3, 3) + " 吨 总支数：" + sum4 + " 支";
    parent.hidesubmenu(true);
</script>
</body>
</html>
